import request from '@/utils/request'
import { makeFormData } from '@/utils/util'

export const api = {
  list: 'api/xj_target/getList',
  submit: 'api/xj_target',
  getTargetDetail: 'api/xj_target/details',
  targetList: '/api/xj_target_class/list',
  targetApi: 'api/xj_target_class',
  targetCard: 'api/xj_target_class/cardCode',
  proList: 'api/xj_target/project_list',
  proParent: 'api/xj_target/get_parent',
  proSubmit: 'api/xj_target/add_project',
  proUpdate: 'api/xj_target/update_project',
  copyCommon: 'api/xj_target_class/copyCommon',
  areaTypeCount: 'api/xj_target_record/area_type_name_count',
  stopType: 'api/xj_target/stop',
  usingType: 'api/xj_target/using',
  stopProject: 'api/xj_target/stop_project',
  checkDetail: 'api/xj_target_record/details'
}

export function submitApi (params = {}, data = {}, method = 'post') {
  return request({
    url: api.submit,
    method,
    params,
    data: makeFormData(data)
  })
}

export function targetSubmit (params = {}, data = {}, method = 'post') {
  return request({
    url: api.targetApi,
    method,
    params,
    data: makeFormData(data)
  })
}

export function getTargetDetail (data = {}, method = 'post') {
  return request({
    url: api.getTargetDetail,
    method,
    data: makeFormData(data)
  })
}

export function sendCard (params = {}) {
  return request({
    url: api.targetCard,
    method: 'post',
    params
  })
}

export function proList (params = {}) {
  return request({
    url: api.proList,
    method: 'post',
    params
  })
}

export function proParent (params = {}) {
  return request({
    url: api.proParent,
    method: 'post',
    params
  })
}

export function proSubmit (params = {}) {
  return request({
    url: api.proSubmit,
    method: 'post',
    params
  })
}

export function proUpdate (params = {}) {
  return request({
    url: api.proUpdate,
    method: 'post',
    params
  })
}

export function copyCommon (params = {}) {
  return request({
    url: api.copyCommon,
    method: 'post',
    params
  })
}

export function areaTypeCount (params = {}) {
  return request({
    url: api.areaTypeCount,
    method: 'post',
    params
  })
}
// 停用巡检类别
export function stopType (params = {}) {
  return request({
    url: api.stopType,
    method: 'post',
    params
  })
}
// 启用
export function usingType (params = {}) {
  return request({
    url: api.usingType,
    method: 'post',
    params
  })
}

// 删除巡检项目
export function stopProject (params = {}) {
  return request({
    url: api.stopProject,
    method: 'post',
    params
  })
}
// 查询所有类别
export function getTypeList (params = {}) {
  return request({
    url: api.list,
    method: 'post',
    params
  })
}

export function checkDetail (params = {}) {
  return request({
    url: api.checkDetail,
    method: 'post',
    params
  })
}
